package GuLi_Java;
//import java.util.Random;
public class Practice01 {
    public static void main(String[] args) {
        // 声明Studenrt类型的数组
        Student[] stu = new Student[20];
        for (int i = 0; i<stu.length; i++){
            // 给数组元素赋值
            stu[i] = new Student();
            // 给Student对象的属性付汇
            stu[i].number = (i+1);
            //年级[1,6]
            stu[i].state = (int)(Math.random() * (6-1+1)+1);
            //成绩[0,100]
            stu[i].score = (int)(Math.random() * (100-0+1));

        }
        for (int i = 0;i<stu.length;i++){
            System.out.println(stu[i].number+" "+ stu[i].state + " " + stu[i].score);
        }
        for (int i = 0;i<stu.length;i++){
            if (stu[i].state == 3){
                System.out.println(stu[i].info());
            }
        }
//        冒泡排序
        for (int i =0; i<stu.length-1;i++){
            for (int j = 0;j<stu.length-1-i;j++){
                if (stu[j].score > stu[j+1].score){
                    // 交换对象为对象而非成绩
                    Student temp = stu[j];
                    stu[j] = stu[j+1];
                    stu[j+1] = temp;
                }

            }
        }
        for (int i = 0;i< stu.length;i++){
            System.out.println(stu[i].info());
        }
    }

}
class Pritimive{
    boolean[] t = new boolean[3];
}
class Array{
    public static void main(String[] args) {
        Pritimive p = new Pritimive();
        for (int i = 0 ;i<p.t.length;i++){
            System.out.print(p.t[i] + "\t");
        }

        for (int i = 0;i<p.t.length;i++){
            p.t[i] = true;
        }
        for (int i = 0;i<p.t.length;i++){
            System.out.print(p.t[i] + "\t");
        }
    }
}

class Student{
    int number;
    int state;
    int score;

    public String info(){
        return "学生信息如下，学号为:"+number + "年级：" + state + "成绩："+ score;
    }


}